<!DOCTYPE html>
<html>
<head>
    <title>WebSocket Demo</title>
    <script type="text/javascript" src="./static/sockjs.min.js"></script>
    <script type="text/javascript" src="./static/stomp.min.js"></script>
</head>
<body>
<div id="content"></div>

<script type="text/javascript">
    var socket = new SockJS('/websocket');
    var stompClient = Stomp.over(socket);

    stompClient.connect({}, function (frame) {
        stompClient.subscribe('/topic/data', function (message) {
            var data = JSON.parse(message.body);
            // 更新数据
            let elementById = document.getElementById("content");
            elementById.innerHTML = data
        });
    });
</script>
</body>
</html>